package cn.stylefeng.guns.fremework;

import lombok.Data;

import java.io.Serializable;

/**
 * 接口报文响应体 kingk
 */
@Data
public class ResponseData implements Serializable {
//FIXME 序列化
    private static final long serialVersionUID = 1L;
//FIXME 基础属性
    private Boolean result;
    private String message;
    private Integer code;
    private Object data;
//FIXME 构造器
    public ResponseData(Boolean result, Integer code, String message, Object data) {
        this.result = result;
        this.message = message;
        this.code = code;
        this.data = data;
    }
//FIXME 成功响应
    public static ResponseData success(){
        return new ResponseData(true,200,"操作成功",null);
    }
    public static ResponseData success(Object data){
        return new ResponseData(true,200,"操作成功",data);
    }
    public static ResponseData success(String message, Object data){
        return new ResponseData(true,200,message,data);
    }
//FIXME 异常响应
    public static ResponseData error(){
        return new ResponseData(false,500,"操作失败",null);
    }
    public static ResponseData error(String message){
        return new ResponseData(false,500,message,null);
    }
    public static ResponseData error(Integer code,String message){
        return new ResponseData(false,code,message,null);
    }


}
